UML and XML

Reading and Understanding UML and XML


What they are and what they are used for. Structure, components and applicationsin the geospatial world.


SADL KU Leuven

WELCOME!

With the following slides and interactive material you will be able to take part in the journey to discover Spatial Data Infrastructures (SDI) its components and benefits through the observation of multiple examples and exercises. 


You can navigate through the course by pressing the navigation arrows at the bottom of each slide or using your arrow keys on your keyboard. You can move horizontally (← →) for viewing each theme and vertically (↑↓) to view extra recommended information


navigation arrows

Reading and Understanding UML and XML


What they are and what they are used for. Structure, components and applicationsin the geospatial world.


SADL KU Leuven

01 Extensible Markup Language XML

#Content
1What is XML and what is it used for?
2XML to Structure Data
3Syntax
4Why XML?
5Validation of XML
6XML schema
7XML namespaces
8XML Examples
9XML Exercise

01 What is XML and what is it used for?

01 | Introduction

In standards, metadata, data models and geospatial services XML and UML are frequently used. Therefore a basic knowledge about reading and understanding XML and UML is important.





Let’s start with XML

01 | 02 What is XML and what is it used for?

XML: eXtensible Markup Language

  • It is a markup language: a set of rules for encoding data in specific format to communicate between machines and with humans i.e., both human readable and machine-readable
  • World Wide Web Consortium (W3C) recommendation
  • Designed to structure, describe and transport data in textual format.
  • <Tags> are fundamental in every MarkUp Language;
  • <Tags> are nested to build structure
  • XML doesn’t DO anything

01 | 02 What is XML and what is it used for?

XML is NOT HTML


  • In XML you define your own tags. (in HTML tags are predefined)
  • Hypertext Markup Language (HTML) – used to display information on web pages
  • HTML does not fully conform to the XML rules

01 XML to structure data

Relational database table:





Table name: Parcel

Column names on the first row

A relational table can easily be expressed in XML

01 | 01 XML to structure data

Same data in XML:

Values are within the tags

01 | 01 | 02 XML to structure data

Important terms:

XML declaration

Root element

Start tag

End tag

Child

Parent

4

01 | 01 XML syntax

XML tagging rules

  • Tags are enclosed in angle brackets <> and come in pairs
    • All start tags <tag>
    • All end tags </tag>
  • Tags are case sensitive
  • Tags must be properly nested
    • <painting><caption></painting></caption> is not allowed
    • <painting><caption>…</caption></painting>is correct

01 | 02 XML syntax

XML Element

An XML element is everything from (including) the element's start tag to (including) the element's end tag.

An element can contain:

  • text
  • Attributes (see later)
  • other elements
  • or a mix of the above

An empty element can be written as <tag/> (=<tag></tag>)

01 | 03 XML syntax

XML Attributes

  • Used to provide extra information about an element
  • Are contained within a start element tag
  • Syntax: attributename=“value” (attribute values quoted)

  • Can be included in empty elements


01 | 03 XML syntax

No rules or preferences between element or tag:

Both are the same:

01 | 04 Why XML?

Self documenting. People can read and understand the data.

    •Standard tools can be used – no need to create custom tools to read/display data.

    •Standard tools ensure data integrity.

    •Can leverage a whole world of XML technologies and tools!

    •Easy to integrate different kinds of data.

01 | 04 Why XML?

01 | 04 Why XML?

01 | 05 Validation of XML

  • Well formed XML document – adhere to the general XML rules
  • Valid XML documents – follow semantic rules
    • The grammar of an XML documents
    • Tells an application – and people – what each element means and how to use it
    • Specify rules that a large set of documents must follow
  • XML schema (.XSD file; XML Schema Definition)
  • In older versions: DTD (Document Type Definition)

01 | 06 XML Schema

An XML schema can define

  • Element names
  • Data types
  • Minimum/maximum occurences

01 | 06 XML Schema

Validation tools can compare an XML document and check if it adheres to the rules defined in the schema.

Examples:

  • if minOccurs in the XML schema is 1, the element must be present.
  • If an attribute is not defined in the schema, it should not be present in the XML file

01 | 07 XML Namespaces

When working with documents from different sources, conflict can arise because the same element name (table) might have different meanings in different documents.





By adding prefixes to xml tag or attribute names, we create namespaces.

01 | 07 XML Namespaces

Namespaces must be defined in the start-tag of the element where it is used. For this the xmlns attribute is used. This declaration can also be done in the XML root element

01 | 07 XML Namespaces

The URI in the namespace definition doesn’t need to be valid (resolvable).

But often in points to an URL that contains information about the namespace. It can be used to point to the XML schema definition of that namespace!

This is for example used in standards





This can greatly help to analyse a XML document

01 | 08 XML Examples


Example XML file from Inspire protected sites

Example XML schema document

01 | 08 XML Exercise

Which XML elements are invalid, and why


1.1 <map/>

1.2 <map>Belgium<map/>

1.3 <map>Belgium</map>

1.4 <map country=Belgium>in Europe</map>

1.5 <building>school<building>

1.6 <building floors=“3”>school</building>

1.7 <Map>Africa<map>

XML exercise

2.1 Indicate the root element


2.2 How many children has Parcel?


01 Unified Modeling Language UML

#Content
1What is UML?
2UML Class diagrams
3UML Associations
4UML Dependency
5UML Generalisation
6UML Aggregation
7UML Composition
8Exercise: UML Simple features

02 | 01 Unified Modeling Language UML

  • Family of graphical notations, aimed for the design of software
  • Consists of several different types of diagrams
  • We will look on class diagrams
  • For classes, features and relationships
  • The conceptual language for ISO TC211 standards

02 | 01 Unified Modeling Language UML

02 | 02 UML Class diagrams

A class is a description of a set of

objects that share the same attributes, operations, relationships, and semantics.


In UML it is drawn as a rectangle:

It contains

  • the class name
  • Attributes
  • Operations

02 | 02 UML Class diagrams - Atributes

For the attributes of a class,

the type is defined, for example float or string

Attributes with different prefix have different visibility


+ are always visible

# is protected

- is private



In the example: not everybody can see the owner

02 | 02 UML Class diagrams - Relations

In UML, interconnections between objects (logical or physical) are modelled as relationships



UML has different kind of relationships:

  • Dependencies
  • Generalisations
  • Associations

Relations can have cardinality

02 | 03 UML Associations

Classes that need to communicate with each other, are linked by association.

An association

  • can have a direction
  • can have a role
  • Can have a cardinality

More than one relation can

exist between 2 classes

02 | 04 UML Dependency

A class depends on another one because the other one is used in its functions.

02 | 05 UML Generalisation

Connects sub- and superclass. Subclasses inherit from the superclass. The superclass is more general, the subclass is a specialised version of the superclass

02 | 06 UML Aggregation

A whole-part relationship. The parts can exist without the whole.






02 | 07 UML Composition

Composition = strong ownership, coincident lifespan

In the example, if the window disappears, the menu and scrollbar also disappear

02 | 08 Exercise: UML Simple features

  1. How many points can a LineString have
  2. What is the relation between Multipoint and point
  3. Is a Polygon a Geometry

Reference list


  • Berardi, Daniela, Calvanese, Diego, & De Giacomo, Giuseppe. (2005). Reasoning on UML class diagrams. Artificial Intelligence, 168(1), 70-118. DOI: 10.1016/j.artint.2005.05.003

  • Jetlund, Onstein, & Huang. (2019). Adapted Rules for UML Modelling of Geospatial Information for Model-Driven Implementation as OWL Ontologies. ISPRS International Journal of Geo-information, 8(9), 365.

  • Van Damme, S. (2017). Trailer UML Class Diagrams for Software Engineering. Leuven: LIMEL